import java.util.*;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2025-02-25
 * Time: 20:35
 */
public class Two {
    public static int[] sumTwo(int[] num, int target) {
        //值，下标
        Map<Integer,Integer> hash = new HashMap<>();

        for(int i = 0; i < num.length; i++) {
            int sum = target-num[i];
            if(hash.containsKey(sum)) {
                return new int[]{i,hash.get(sum)};
            }
            hash.put(num[i],i);
        }
        return null;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] num = new int[n];
        for(int i = 0; i < n; i++) {
            num[i] = sc.nextInt();
        }
        int target = sc.nextInt();
        int[] ret = new int[2];
        ret = sumTwo(num,target);
        for(int i = 0; i < 2; i++) {
            System.out.print(ret[i]+" ");
        }
    }
}
